<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
</html>

<script>
// 英文：
  // target - 目标

/* 
  3. 编写函数has(arr , 60) 判断数组中是否存在60这个元素，返回布尔类型

    ```javascript
    var arr = [1, 2, 3, 60]
    var arr2 = [1, 2, 3]
    
    function has() {
      // code in here ...
    }
    
    console.log(has(arr, 60)) // true
*/

/* 
 * 判断 searchElement 是否出现在 arr 中
 *
 * @param {Array} arr
 * @param {Number} searchElement
 * @return {Boolean}
*/
function has(arr, searchElement) {
  return arr.indexOf(searchElement) !== -1;
}

// console.log(has([1, 2, 2, 3], 2));


// ---------- ES6新增的方法：Array.prototype.includes(searchElement) ---------------
// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
console.log([1, 2, 2, 3].includes(1));
</script>